package com.kjlink.internal.report4vue.task;


import cn.xuqiudong.quartz.annotation.TaskJobFlag;
import cn.xuqiudong.quartz.helper.JobUserHolder;
import cn.xuqiudong.quartz.job.AbstractTaskJob;
import cn.xuqiudong.quartz.model.TaskJobLog;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalTime;

/**
 * 描述:
 * demo 任务
 *
 * @author Vic.xu
 * @since 2025-01-20 14:07
 */
@Component
public class DemoTask extends AbstractTaskJob {


    @Transactional(rollbackFor = Exception.class)
    @TaskJobFlag(value = "demo.one", text = "第一个demo任务")
    public String demoOne(TaskJobLog taskJobLog) {
        String username = JobUserHolder.getUserNameNotNull();
        logger.info("运行第一个demo任务:｛｝", username);
        return LocalTime.now() + " 运行第一个demo任务成功:" + username;
    }

    @Cacheable(value = "demo.two")
    @TaskJobFlag(value = "demo.two", text = "第二个demo任务")
    public String demoTwo(TaskJobLog taskJobLog) {
        String username = JobUserHolder.getUserNameNotNull();
        logger.info("运行第二个demo任务:｛｝", username);
        return LocalTime.now() + " 运行第二个demo任务成功:" + username;
    }
}
